home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / gnu / amiga / bmake15.lzh / snode.c < prev    next >
C/C++ Source or Header  |  1991-07-10  |  1KB  |  64 lines

  1. /*    snode.c
  2.  *    (c) Copyright 1991 by Ben Eng, All Rights Reserved
  3.  *
  4.  */
  5.  
  6. #include <ctype.h>
  7.  
  8. #include "make.h"
  9.  
  10. struct string_node *
  11. new_snode( const char *str )
  12. {
  13.     struct string_node *new;
  14.     
  15.     if( new = malloc( sizeof(*new) + strlen( str ) )) {
  16.         strcpy( new->data, str );
  17.         new->node.ln_Name = new->data;
  18.         new->node.ln_Type = (UBYTE)NT_USER;
  19.         new->node.ln_Pri = 0;    /* Priority, for sorting */
  20.     }
  21.     return( new );
  22. }
  23.  
  24. struct string_node *
  25. renew_snode( const struct string_node *old, const char *str )
  26. {
  27.     struct string_node *new;
  28.     
  29.     if( new = realloc( old, sizeof(*new) + strlen( str ) )) {
  30.         strcpy( new->data, str );
  31.         new->node.ln_Name = new->data;
  32.     }
  33.     return( new );
  34. }
  35.  
  36. struct string_node *
  37. delete_snode( struct string_node *old )
  38. {
  39.     free( old );
  40.     return( NULL );
  41. }
  42.  
  43. void
  44. delete_slist( struct List *list )
  45. {
  46.     for_list( list, delete_snode );
  47.     NewList( list );
  48. }
  49.  
  50. #if DEBUG
  51. int
  52. print_snode( struct string_node *old )
  53. {
  54.     printf( "snode: %s\n", old->data );
  55.     return( 0 );
  56. }
  57.  
  58. void
  59. print_slist( struct list *list )
  60. {
  61.     for_list( list, print_snode );
  62. }
  63. #endif
  64.